<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateOrderCouponSplite extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        return ;
        for ($i = 0; $i <= 99; $i++) {

            $name = str_pad($i, 3, 0, STR_PAD_LEFT);

            Schema::connection("mysqlOrder")->create('order_coupon_' . $name, function (Blueprint $table) use ($name) {
                $table->unsignedBigInteger('id')->default(0)->comment("主键 id");
                $table->unsignedInteger("brandId")->default(0)->comment("品牌 Id");
                $table->unsignedInteger("shopId")->default(0)->comment("店铺 ID");
                $table->unsignedBigInteger('orderId')->default(0)->comment("订单 ID");
                $table->unsignedBigInteger('customerCouponId')->default(0)->comment("用户关联优惠券 Id");
                $table->unsignedBigInteger('couponId')->default(0)->comment("原始优惠券ID");
                $table->tinyInteger("status")->default(0)->comment("0:待核销 1:已使用 2:已撤销");
                $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");

                $table->primary('id', 'idx_id');        // 主键非自增
                $table->index("orderId", "idx_orderId");
                $table->index("shopId", "idx_shopId");

                $table->collation = 'utf8mb4_general_ci';
                $table->comment   = '订单优惠券核销表_' . $name;
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
//        for ($i = 0; $i <= 99; $i++) {
//            $name = str_pad($i, 3, 0, STR_PAD_LEFT);
//            Schema::connection("mysqlOrder")->dropIfExists('order_coupon_' . $name);
//        }
    }
}
